package com.maizhi.model;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.UUID;


public class UID {
	
	//随机且唯一字符串ID
	public static String getUUIDs(){
		String s= UUID.randomUUID().toString();
		return s.replace("-","");
	}
	
	
	//以时间YYYYMMddHHmiss 格式数字作为唯一ID
	public static Long getUUIDi(){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
		return Long.parseLong(sdf.format(new Date()));
	}
	
	
	//以前缀+时间为方式作为工单编号
	public static String getTaskId(String prefix){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
		return (prefix.equals("")||prefix==null?"":prefix)+sdf.format(new Date());
	}
	
	public static void main(String[] args){
		System.out.println(UID.getTaskId("RX"));
		System.out.println(UID.getTaskId(""));
		System.out.println(UID.getUUIDs());
		System.out.println(String.valueOf(UID.getUUIDi()));
		
		Date date = new Date();
		System.out.println(date.getYear());
		System.out.println(date.getMonth());
		 
		 
	}
}
